package lt.marsrutai.mobile.android.activity;

import lt.marsrutai.mobile.android.R;
import lt.marsrutai.mobile.android.fragment.RoutesFragment;
import lt.marsrutai.mobile.android.fragment.StopClarificationDialogFragment.StopClarificationDialogListener;
import android.support.v4.app.Fragment;

import com.actionbarsherlock.app.ActionBar;

public class FastestRoutesResultActivity extends BaseActivity implements StopClarificationDialogListener {

    @Override
    protected void setupActionBar(final ActionBar actionBar) {
        super.setupActionBar(actionBar);

        actionBar.setDisplayShowTitleEnabled(true);
        actionBar.setTitle(getString(R.string.fastest_routes));
    }

    @Override
    protected int getNavigationMode() {
        return ActionBar.NAVIGATION_MODE_STANDARD;
    }

    @Override
    public void setupView() {
        if (getSupportFragmentManager().findFragmentById(android.R.id.content) == null) {
            Fragment fragment = new RoutesFragment();
            fragment.setArguments(getIntent().getExtras());
            getSupportFragmentManager().beginTransaction().add(android.R.id.content, fragment).commit();
        }
    }

    @Override
    public void onDialogClick(int dialogId, String selectedItem) {
        RoutesFragment fragment = (RoutesFragment) getSupportFragmentManager().findFragmentById(android.R.id.content);

        if (fragment != null) {
            fragment.onClarificationDialogItemSelected(dialogId, selectedItem);
        }
    }

    @Override
    public void onDialogCancel(int dialogId) {
        RoutesFragment fragment = (RoutesFragment) getSupportFragmentManager().findFragmentById(android.R.id.content);

        if (fragment != null) {
            fragment.onClarificationDialogCancelled(dialogId);
        }
    }
}
